FROM colmap:latest
LABEL maintainer="rogers"
ARG PYTHON_VERSION=3.10

# 设置环境变量为非交互模式
ENV DEBIAN_FRONTEND=noninteractive

# 备份原始sources.list并配置阿里云镜像源
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak && \
    echo "deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse" > /etc/apt/sources.list && \
    echo "deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse" >> /etc/apt/sources.list && \
    echo "deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
    echo "deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse" >> /etc/apt/sources.list

# 更新软件包列表并安装基础工具
RUN apt-get update -y && \
    apt-get install -y git unzip wget software-properties-common


RUN apt-get -y update && \
    apt-get install -y python${PYTHON_VERSION}

RUN wget https://bootstrap.pypa.io/get-pip.py && python${PYTHON_VERSION} get-pip.py -i https://mirrors.aliyun.com/pypi/simple/
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1
COPY . /app
WORKDIR app/

# 配置pip使用国内镜像源
RUN pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
    pip3 config set install.trusted-host mirrors.aliyun.com && \
    pip3 config set global.timeout 300 && \
    pip3 config set global.retries 5

# 升级pip并安装依赖
RUN pip3 install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/ && \
    pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ && \
    pip3 install notebook -i https://mirrors.aliyun.com/pypi/simple/

